ARG NEXUS_URL=tsnnlx12bs02:8082
FROM ${NEXUS_URL}/ubuntu:22.04

ARG NEXUS_URL=tsnnlx12bs02:8082
ENV NEXUS_URL=$NEXUS_URL

WORKDIR /data

RUN apt-get update \
    && apt-get -y install \
        binutils \
        gnupg \
        flex \
        bison \
        gperf \
        build-essential \
        zip \
        curl \
        zlib1g-dev \
        gcc-multilib \
        g++-multilib \
        libc6-dev-i386 \
        lib32ncurses-dev \
        x11proto-core-dev \
        libx11-dev \
        lib32z1-dev \
        ccache \
        libgl-dev \
        libgl1-mesa-dev \
        libxml2-utils \
        xsltproc \
        unzip \
        m4 \
        bzip2 \
        git \
        git-lfs \
        python3 \
        python3-pip \
        vim \
        python2 \
        gcc-arm-none-eabi \
        libelf-dev \
        default-jdk \
        genext2fs \
        u-boot-tools \
        mtools \
        mtd-utils \
        scons ruby \
        libssl-dev \
        libtinfo5 \
        liblz4-tool \
        openssl \
        libxcursor-dev \
        libxrandr-dev \
        libxinerama-dev \
        g++-multilib \
        gcc-multilib \
        bc \
        xorg-dev \
        gnutls-bin \
        libc++1 \
        android-sdk-libsparse-utils \
        libtinfo-dev \
        rpm2cpio

# additional packages
RUN apt-get install -y \
       gcc-arm-linux-gnueabi \
    && apt-get install -y python-is-python3 \
    && apt-get install -y gdb meson lcov cmake make ninja-build locales wget sudo cpio \
    && sed -i -e 's/%sudo\s*ALL=(ALL:ALL)\s*ALL/%sudo   ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers

# install repo and pip packages
RUN curl -Lko /usr/bin/repo "https://gitee.com/oschina/repo/raw/fork_flow/repo-py3" \
    && chmod a+x /usr/bin/repo \
    && python3 -m pip install pip --upgrade --no-cache-dir \
    && python3 -m pip install wheel setuptools --upgrade \
    && python3 -m pip install -i https://repo.huaweicloud.com/repository/pypi/simple \
        requests \
        pymongo \
        kconfiglib \
        pycryptodome \
        ecdsa \
        ohos-build \
        pyyaml \
        prompt_toolkit==1.0.14 \
        redis \
        json2html \
        yagmail \
        python-jenkins \
        testresources \
    && python3 -m pip install esdk-obs-python --trusted-host pypi.org \
    && python3 -m pip install six --upgrade --ignore-installed six \
    && python3 -m pip install meson==0.62.0

# install npm
#RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/refs/heads/master/nvm.sh | bash

# make sudo without password


# Switch dash to bash
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo "dash dash/sh boolean false" | debconf-set-selections \
    && DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash \
    && sed --in-place '/en_US.UTF-8/s/^#//' /etc/locale.gen \
    && locale-gen

# Configure locale
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8


# script for internal configuration and usercreation
COPY run_inside.sh /bin
RUN chmod +x /bin/run_inside.sh
ENTRYPOINT ["/bin/run_inside.sh"]
